home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / SWAG9605.DDD / 0092_Display ANSI files FAST.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-05-31  |  2.1 KB  |  61 lines

  1. {
  2. The reason is because when you are using the CRT unit, the write() and
  3. writeln() commands use direct writes.  Direct writes?  Direct writes are
  4. direct writes to video memory (at $b800:0000), not going through BIOS.
  5. Therefore, ANSI.SYS never even SEES what you write to the screen when
  6. the CRT unit is being used, and therefore cannot interperate the ansi
  7. sequences as colors, cursor movements, and so on.  So if you want to use
  8. ANSI.SYS to decode your ansi screens, but also want to have the CRT unit
  9. installed, you must make your own "write()" type procedure which doesn't
  10. go directly to the screen.  Here is one:
  11.  
  12. procedure ansiwrite(c:char); assembler;
  13. asm
  14.   mov ah,2
  15.   mov dl,c
  16.   int 21h
  17. end;
  18.  
  19. To display an ansi using this procedure, give it one character at a time.
  20. However, this is going to be extremely slow.  Using this same code (with a
  21. small amount of modification and additional junk), you could speed up the
  22. ansi file displaying process dramatically.  Here is an example program, all
  23. tested, that will display an ansi, with the CRT unit installed, quickly...
  24. I'm sure someone out there has got a better way, but this is the quickest
  25. that I know of.  :)
  26.  
  27. { -- CUT HERE -- }
  28.  
  29. program displayansi;
  30.  
  31. uses crt;
  32.  
  33. var buf:array[1..1024] of char; nr,n:word; f:file;
  34.  
  35. begin
  36.   IF Paramcount > 0 THEN
  37.   BEGIN
  38.   assign(f,paramStr(1));
  39.   reset(f,1);
  40.   repeat
  41.     blockread(f,buf,sizeof(buf),nr);
  42.     asm
  43.       mov cx,0               { set our counter to zero }
  44.       @1:                    { top of loop marker }
  45.       add cx,1               { increase it by one }
  46.       cmp cx,nr              { compare CX to nr }
  47.       jg  @2                 { CX greater than nr, jump to @2 }
  48.       mov bx,cx              { move CX into BX }
  49.       mov si,offset buf      { move "buf" offset into SI }
  50.       mov dl,[si+bx-1]       { copy byte from "buf" into DL }
  51.       mov ah,2               { function 2 into AH }
  52.       int 21h                { call interrupt 21h }
  53.       jmp @1                 { jump back to @1 and start over - loop }
  54.       @2:                    { asm loop ends here }
  55.     end;
  56.   until (nr=0);
  57.   close(f);
  58.   END;
  59. end.
  60.  
  61.